package network.tpa2;

import java.net.DatagramPacket;
import java.net.InetAddress;

import network.AbstractUserSignal;

/**
 * Classe correspond à un signal utilisateur du groupe TPA2.
 *
 */
public class UserSignalA2 extends AbstractUserSignal {
	
	private byte[] signal = null ;

	/**
	 * Create a new UserSignal corresponding to the packet. The UserSignal
	 * contain information about the signal and the host that sent it.
	 * 
	 * @param packet
	 */
	public UserSignalA2 (DatagramPacket packet) {
		super (packet) ;
		this.signal = packet.getData() ;
	}
	
	/**
	 * Create a new UserSignal corresponding to specified signal and receiver address.
	 * 
	 * @param signal
	 * @param receiver
	 */
	public UserSignalA2 (byte[] signal, InetAddress receiver) {
		super (receiver) ;
		this.signal = signal ;
	}

	public byte[] getSignal () {
		return this.signal ;
	}
	
	@Override
	public byte[] serialize() {
		return this.signal;
	}	
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString () {
		return this.getClass() + " (" + (new MsgDecoder(this.signal)).getTypeMess() + ")" ;
	}
}
